package com.example.duomeitijuhe.ui.myview;

import android.app.Activity;
import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.ImageButton;
import com.example.duomeitijuhe.R;
import com.example.duomeitijuhe.others.ReducePicture;
import com.example.duomeitijuhe.others.RoundPicture;
import com.example.duomeitijuhe.ui.LoginActivity;
import com.example.duomeitijuhe.ui.MyselfEditActivity;

/**
 * Created by Michael on 2014/10/13.
 */
public class TitleView extends FrameLayout {

    private ImageButton imageButton;

    private Button sureButton;




    Bitmap headBitmap;

    private Context mContext;

    public TitleView( Context context,AttributeSet attributeSet){
        super(context,attributeSet);
        mContext = context;
        if (isInEditMode()) {
            return ;
        }

        View view = LayoutInflater.from(context).inflate(R.layout.title, this);
        imageButton = (ImageButton)view.findViewById(R.id.head_image);
        headBitmap = getHeadBitmap();

        imageButton.setImageBitmap(headBitmap);
        Log.e("imageButton","imageButton");
        imageButton.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(mContext,LoginActivity.class);
                mContext.startActivity(intent);
            }
        });
        sureButton = (Button)view.findViewById(R.id.manage_button);
        //addView(view);


    }
    public Bitmap getHeadBitmap(){

        ReducePicture reducePicture = new ReducePicture(mContext);
        Bitmap bitmap = reducePicture.pictureToLess(R.drawable.default_head_icon,30);
        RoundPicture roundPicture = new RoundPicture();
        Bitmap bitmap1 = roundPicture.toRoundBitmap(bitmap);
        return bitmap1;
    }
}
